package com.rimi.project.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rimi.project.bean.User;
import com.rimi.project.dao.UserDao;
import com.rimi.project.dao.impl.UserDaoImpl;

@WebServlet("/user/check")
public class CheckServlet extends HttpServlet{
	UserDao userDao = new UserDaoImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("utf-8");
		
		String userName = req.getParameter("registerusername");

		User user = userDao.findUserByAcc(userName);
		
		if (null != user) {
			resp.getWriter().print(false);
		} else {
			resp.getWriter().print(true);
		}
		
	}
}
